#include<bits/stdc++.h>
using namespace std;
long long T,n,x1[200009],x2[200009],xl=0,yl=0,cnt=0,ans=0;
void qwe(){
	for(long long i=1;i<=n;i++){
		if(x2[i]==1){
			if((xl!=0)&&(x1[xl]==x1[i]))cnt+=x1[i];
			xl=i;
		}
		if(x2[i]==0){
			if((yl!=0)&&(x1[yl]==x1[i]))cnt+=x1[i];
			yl=i;
		}
		return;
	}
	ans=max(ans,cnt);
	cnt=0,xl=0,yl=0;
}
void dfs(long long x){
	if(x==n+1){
		qwe();
		return;
	}
	else{
		x2[x]=1;
		dfs(x+1);
		x2[x]=0;
		dfs(x+1);
	}
}
int main()
{
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	scanf("%lld",&T);
	for(long long i=1;i<=T;i++){
		scanf("%lld",&n);
		for(long long i=1;i<=n;i++)scanf("%lld",&x1[i]);
		dfs(1);
		printf("%lld\n",ans);
		ans=0;
	}
	return 0;
}
